package com.education.service.impl;


import com.education.dao.*;
import com.education.pojo.*;
import com.education.service.SelectTestPeper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * Created by Administrator on 2018/4/23.
 * 根据科目和班级查询试卷
 */
@Service
public class SelectTestPeperImpl implements SelectTestPeper{
    @Autowired
    private SubjectMapper subjectMapper;
    @Autowired
    private GradeMapper gradeMapper;
    @Autowired
    private TestPaperMapper testPaperMapper;
    @Autowired
    private StudyOnlineMapper studyOnlineMapper;
    @Autowired
    private ExampleQuestionsMapper exampleQuestionsMapper;
    @Autowired
    private UserCollectionMapper userCollectionMapper;


    @Override
    public List<TestPaper> getTestPeper(Integer gId, Integer sid, String tpname) {
        List<TestPaper> list = testPaperMapper.selectBySubjectIdAndGradeId(sid,gId,tpname);
        System.out.println(list);
        return list;
    }

    @Override
    public Grade getGradeId(String gname) {
        return gradeMapper.selectByGradeName(gname);
    }

    @Override
    public Subject getSubjectId(String sname) {
        return subjectMapper.selectBySubjectName(sname);
    }

    @Override
    //获取所有的在线学习的信息
    public List<StudyOnline> getAllStudyOnline() {
        return studyOnlineMapper.selectAllInformation();
    }

    //根据试卷ID获取对应的题
    @Override
    public List<ExampleQuestions> getAllExampleQustionByID(Integer tpId) {
        return exampleQuestionsMapper.selectExampleQuestionByTpID(tpId);
    }

    @Override
    //添加数据到我的收藏表
    public int insertdatatoUserCollection(UserCollection userCollection) {
        return userCollectionMapper.insert(userCollection);
    }

    @Override
    //根据用户ID和试卷ID查询我的收藏表
    public List<UserCollection> selectByUidAndTpid(Integer uid, Integer tpid) {
        return userCollectionMapper.selectByUidAndTpid(uid,tpid);
    }
}
